//
//  ViewController.m
//  10604
//
//  Created by student on 16/3/2.
//  Copyright © 2016年 NIIT. All rights reserved.
//

#import "ViewController.h"

#define kScreenWidth [UIScreen mainScreen].bounds.size.width
#define kScreenHeight [UIScreen mainScreen].bounds.size.height
// 竖屏使用
#define W(x) (x * kScreenWidth / 320.0)
#define H(y) (y * kScreenHeight / 568.0)
// 横屏使用
#define WR(y) (y * kScreenHeight / 320.0)
#define HR(x) (x * kScreenWidth / 568.0)


@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIButton *btn;
@property (weak, nonatomic) IBOutlet UIButton *label1;
@property (weak, nonatomic) IBOutlet UIButton *label2;
@property (weak, nonatomic) IBOutlet UIButton *label3;
@property (weak, nonatomic) IBOutlet UIButton *label4;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        // 水平方向
        self.btn.frame = CGRectMake(WR(20),HR(20),WR(280),HR(280));
        self.label1.frame = CGRectMake(WR(330),HR(20),WR(100),HR(40));
        self.label2.frame = CGRectMake(WR(330),HR(100),WR(100),HR(40));
        self.label3.frame = CGRectMake(WR(330),HR(180),WR(100),HR(40));
        self.label4.frame = CGRectMake(WR(330),HR(260),WR(100),HR(40));
    }
    else
    {
        // 垂直方向
        self.btn.frame = CGRectMake(W(20),H(31),W(280),H(280));
        self.label1.frame = CGRectMake(W(20),H(351),W(71),H(30));
        self.label2.frame = CGRectMake(W(229),H(351),W(71),H(30));
        self.label3.frame = CGRectMake(W(20),H(431),W(71),H(30));
        self.label4.frame = CGRectMake(W(229),H(431),W(71),H(30));
    }

}




















@end
